Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 5626342cbfb8be24fe7ec5f53cdf9f919c5e1fb1


Parents : 14cd17c
Author : Mark Qvist <mark@unsigned.io>
Date : 2023-08-15T12:45:41+02:00

Increased MDSwitch hit zone

Changes
Diff

diff --git a/sbapp/kivymd/uix/selectioncontrol/selectioncontrol.kv b/sbapp/kivymd/uix/selectioncontrol/selectioncontrol.kv
index 3d3b015f..5d0a44c0 100644
--- a/sbapp/kivymd/uix/selectioncontrol/selectioncontrol.kv
+++ b/sbapp/kivymd/uix/selectioncontrol/selectioncontrol.kv
@@ -137,9 +137,11 @@
) \
) \
)
+
on_touch_down:
if self.collide_point(*args[1].pos) and not root.disabled: \
root.on_thumb_down()
on_touch_up:
- if self.collide_point(*args[1].pos) and not root.disabled: \
- setattr(root, "active", not root.active)
+ if self.collide_point(*args[1].pos) and not root.disabled: setattr(root, "active", not root.active)
+ elif root.collide_point(*args[1].pos) and not root.disabled: setattr(root, "active", not root.active)
+ else: root.tnn(args[1])

diff --git a/sbapp/kivymd/uix/selectioncontrol/selectioncontrol.py b/sbapp/kivymd/uix/selectioncontrol/selectioncontrol.py
index 6bcefe67..be03df0b 100755
--- a/sbapp/kivymd/uix/selectioncontrol/selectioncontrol.py
+++ b/sbapp/kivymd/uix/selectioncontrol/selectioncontrol.py
@@ -829,6 +829,23 @@ class MDSwitch(ThemableBehavior, FloatLayout):
Clock.schedule_once(lambda x: self._update_thumb_pos(animation=False))
Clock.schedule_once(lambda x: self.on_active(self, self.active))
+ # Hack to increase switch hit zone
+ def tnn(self, pa):
+ try:
+ ex = pa.pos[0]
+ ey = pa.pos[1]
+ xs = self.center[0]-self.width/2 - (self.width)
+ xe = self.center[0]+self.width/2 + (self.width)
+ ys = self.center[1]-self.height/2
+ ye = self.center[1]+self.height/2
+
+ # print(str(xs)+" < "+str(ex)+" < "+str(xe)+" "+str(ys)+" < "+str(ey)+" < "+str(ye))
+ if xs < ex < xe and ys < ey < ye:
+ self.active = not self.active
+
+ except Exception as e:
+ pass
+
def set_icon(self, instance_switch, icon_value: str) -> None:
"""
Called when the values of


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────